home *** CD-ROM | disk | FTP | other *** search
/ Exame Informatica 140 / Exame Informatica 140.iso / Programas / WorldWind / World_Wind_1.4.0_RC2.exe / Shaders / grayscale.fx < prev    next >
Encoding:
Text File  |  2006-12-18  |  1.3 KB  |  72 lines

  1. struct VS_OUTPUT
  2. {
  3.     float4 pos    :    POSITION;
  4.     float4 color    :    COLOR;
  5.     float2 texCoord    :    TEXCOORD0;
  6. };
  7.  
  8. texture Tex0;
  9. float4x4 WorldViewProj    :    WORLDVIEWPROJECTION;
  10. float Opacity = 1.0;
  11. float Brightness = 0.0;
  12.  
  13. VS_OUTPUT VS(
  14.     float4 Pos    :    POSITION,
  15.     float4 Norm : NORMAL,
  16.     float2 texCoord    :    TEXCOORD0)
  17. {
  18.     VS_OUTPUT Out = (VS_OUTPUT)0;
  19.     
  20.     // transform Position
  21.     Out.pos = mul(Pos, WorldViewProj);
  22.     Out.color = float4(0,0,0,Opacity);
  23.     Out.texCoord = texCoord;
  24.     
  25.     return Out;
  26. }
  27.  
  28. sampler Sampler = sampler_state
  29. {
  30.     Texture = (Tex0);
  31.     MipFilter = LINEAR;
  32.     MinFilter = LINEAR;
  33.     MagFilter = LINEAR;
  34. };
  35.  
  36. float4 PS(
  37.     float2 Tex : TEXCOORD0) : COLOR
  38. {
  39.     float4 f = tex2D(Sampler, Tex);
  40.     float gray = 0.3 * f.x + 0.59 * f.y + 0.11 * f.z;
  41.     f.xyz = gray;
  42.     f.w = Opacity * f.w;
  43.     return f;
  44. }
  45.  
  46. float4 PS_Brightness(
  47.     float2 Tex : TEXCOORD0) : COLOR
  48. {
  49.     float4 f = tex2D(Sampler, Tex);
  50.     float gray = 0.3 * f.x + 0.59 * f.y + 0.11 * f.z + Brightness / 255.0;
  51.     f.xyz = gray;
  52.     f.w = Opacity * f.w;
  53.     return f;
  54. }
  55.  
  56. technique RenderGrayscaleBrightness
  57. {
  58.     pass P0
  59.     {
  60.         VertexShader = compile vs_1_1 VS();
  61.         PixelShader = compile ps_2_0 PS_Brightness();
  62.     }
  63. }
  64.  
  65. technique RenderGrayscale
  66. {
  67.     pass P0
  68.     {
  69.         VertexShader = compile vs_1_1 VS();
  70.         PixelShader = compile ps_1_1 PS();
  71.     }
  72. }